package com.tdzx.entity;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

public class CircleEntity implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = -6652593980354188119L;
	private String member_id;
	private String cirl_id;
	private String cirl_context;
	private String cirl_imag;
	private String memberName;
	private long date;
	private int commentcount;
	private String isimage;
	
	public int getCommentcount() {
		return commentcount;
	}
	public void setCommentcount(int commentcount) {
		this.commentcount = commentcount;
	}
	public String getIsimage() {
		return isimage;
	}
	public void setIsimage(String isimage) {
		this.isimage = isimage;
	}
	public long getDate() {
		return date;
	}
	public void setDate(long date) {
		this.date = date;
	}
	public String getMember_id() {
		return member_id;
	}
	public void setMember_id(String member_id) {
		this.member_id = member_id;
	}
	public String getCirl_id() {
		return cirl_id;
	}
	public void setCirl_id(String cirl_id) {
		this.cirl_id = cirl_id;
	}
	public String getCirl_context() {
		return cirl_context;
	}
	public void setCirl_context(String cirl_context) {
		this.cirl_context = cirl_context;
	}
	public String getCirl_imag() {
		return cirl_imag;
	}
	public void setCirl_imag(String cirl_imag) {
		this.cirl_imag = cirl_imag;
	}
	public String getMemberName() {
		return memberName;
	}
	public void setMemberName(String memberName) {
		this.memberName = memberName;
	}
	
	public static Map getListCircle(String json) {
		Map map = new HashMap();
		List<CircleEntity> list = null;
		try {
			JSONObject jo = new JSONObject(json);
			JSONArray ja = jo.optJSONArray("resutObject");
			JSONObject jo_t = jo.optJSONObject("cirlEntity");
			if(jo_t != null && !jo_t.equals("null")) {
				CircleEntity title = new CircleEntity();
				title.setCirl_context(jo_t.optString("cirl_context"));
				title.setCirl_id(jo_t.optString("cirl_id"));
				title.setCirl_imag(jo_t.optString("cirl_imag"));
				title.setMember_id(jo_t.optString("member_id"));
				title.setMemberName(jo_t.optString("memberName"));
				title.setDate(jo_t.optLong("cirl_date"));
				map.put("title", title);
			}
			if(ja != null) {
				list = new ArrayList<CircleEntity>();
				for(int i = 0; i < ja.length(); i++) {
					JSONObject jo_c = ja.optJSONObject(i);
					CircleEntity cn = new CircleEntity();
					cn.setCirl_context(jo_c.optString("newcirl_context"));
					cn.setCirl_id(jo_c.optString("newcirl_id"));
					cn.setCirl_imag(jo_c.optString("memberimage"));
					cn.setMember_id(jo_c.optString("member_id"));
					cn.setMemberName(jo_c.optString("memberName"));
					cn.setDate(jo_c.optLong("newcirl_date"));
					cn.setCommentcount(jo_c.optInt("commentcount"));
					cn.setIsimage(jo_c.optString("isimage"));
					list.add(cn);
				}
				map.put("list", list);
			}
		} catch (JSONException e) {
			e.printStackTrace();
		}
		return map;
	}
	
}
